//==================================================================
//  Copyright (C) 2006-2007  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
///
///
///
///
///
//==================================================================

#ifndef GUIBASE_H
#define GUIBASE_H

#include "psys.h"

class Window;
class WindowEvent;

//==================================================================
typedef void	(*GuiBaseDispUpdateCallback)( void *userdatap );
typedef int	(*GuiBaseEventFilterCallback)( void *userdatap, class WindowEvent *eventp );

//==================================================================
class GuiBaseManager
{
	GuiBaseDispUpdateCallback	_dispupdate_cback;
	void						*_dispupdate_cback_userdatap;

	GuiBaseEventFilterCallback	_event_filter_cback;
	void						*_event_filter_cback_userdatap;

public:
	//==================================================================
	GuiBaseManager() :
		_dispupdate_cback(NULL),
		_dispupdate_cback_userdatap(NULL),
		_event_filter_cback(NULL),
		_event_filter_cback_userdatap(NULL)

	{
	}

	//==================================================================
	void	SetEventFilterCallback( GuiBaseEventFilterCallback cback, void *cback_userdatap )
	{
		_event_filter_cback = cback;
		_event_filter_cback_userdatap = cback_userdatap;
	}

	//==================================================================
	void	SetDispUpdateCallback( GuiBaseDispUpdateCallback cback, void *cback_userdatap )
	{
		_dispupdate_cback = cback;
		_dispupdate_cback_userdatap = cback_userdatap;
	}

	//==================================================================
	int	EventFilter( WindowEvent *eventp ) const
	{
		if ( _event_filter_cback )
			return _event_filter_cback( _event_filter_cback_userdatap, eventp );

		return 0;
	}

	//==================================================================
	void	InvalidateDisplay() const
	{
		if ( _dispupdate_cback )
			_dispupdate_cback( _dispupdate_cback_userdatap );
	}
};


#endif
